/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Golf_Manager.model;

import Golf_Manager.vo.Member;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Administrator
 */
public class MemberDialogModel extends AbstractTableModel {
    
    Class[] types = new Class [] {java.lang.String.class, java.lang.String.class};
    private List<Golf_Manager.vo.Member> members = new ArrayList<>();
    private String[] columns = new String [] {"이름", "생년월일"};
    private boolean[] canEdit = new boolean [] { false, false};
    
    @Override
    public Class<?> getColumnClass(int columnIndex) {
        return types[columnIndex];
    }
    
    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return canEdit[columnIndex];
    }
    
    @Override
    public int getRowCount() {
        return members.size();
    }

    @Override
    public int getColumnCount() {
        return columns.length;
    }
    
    @Override
    public String getColumnName(int column) {
        return columns[column];
    }
    
    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch(columnIndex){
            case 0: {
                return members.get(rowIndex).getName();
            }
            case 1: {
                return members.get(rowIndex).getBirth();
            }
            default: {
                return null;
            }
        }
    }

    public List<Member> getMembers() {
        return members;
    }

    public void setMembers(List<Member> members) {
        this.members = members;
         fireTableDataChanged();
    }
    
    public Member getMember(int rowIndex) {
        return members.get(rowIndex);
    }
    
    
    
}
